#include <logbase.h>
#include "queuecommon.h"
struct readerWieganInform
{
    int readerId;
    int wieganSize;
    uint64_t wieganData;
};
struct readerWieganQueue
{
    struct readerWieganInform quedata[10];
    uint32_t quesize; // quesize
    uint32_t readid;
    uint32_t writeid;
    int readflag;
};
static struct readerWieganQueue wieganQueIns;
//check char buffer
struct charBufferQueue
{
    uint8_t quedata[10];
    uint32_t quesize; // quesize
    uint32_t readid;
    uint32_t writeid;
    int readflag;
};
int main(int argc, char **argv)
{
    struct readerWieganInform tmpwg;
    queueCommonInit(wieganQueIns);
    for (int i = 0; i < wieganQueIns.quesize - 1; i++)
    {
        tmpwg = (struct readerWieganInform){i, 0, 0};
        //set
        queueCommonInput(wieganQueIns, tmpwg);
        //get
        queueCommonOutput(wieganQueIns, tmpwg);
        logdebugc("[flag=%d,size=%d][%d,%d]", wieganQueIns.readflag, queueCommonCount(wieganQueIns), tmpwg.readerId, tmpwg.wieganSize);
        //set
        tmpwg.readerId = 1000 + i;
        queueCommonInput(wieganQueIns, tmpwg);
    }
    while (1)
    {
        queueCommonOutput(wieganQueIns, tmpwg);
        if (!wieganQueIns.readflag)
        {
            break;
        }
        logdebugc("[flag=%d,size=%d][%d,%d]", wieganQueIns.readflag, queueCommonCount(wieganQueIns), tmpwg.readerId, tmpwg.wieganSize);
    }
    //char buffer
    struct charBufferQueue tmpcharQue;
    uint8_t tmpCharVal;
    queueCommonInit(tmpcharQue);
    for (int i = 0; i < tmpcharQue.quesize - 1; i++)
    {
        //set
        queueCommonInput(tmpcharQue, i);
        //get
        queueCommonOutput(tmpcharQue, tmpCharVal);
        logdebugc("[flag=%d,size=%d][%d]", tmpcharQue.readflag, queueCommonCount(tmpcharQue), tmpCharVal);
        //set
        queueCommonInput(tmpcharQue, i + 100);
    }
    while (queueCommonCount(tmpcharQue) > 0)
    {
        queueCommonOutput(tmpcharQue, tmpCharVal);
        logdebugc("[flag=%d,size=%d][%d]", tmpcharQue.readflag, queueCommonCount(tmpcharQue), tmpCharVal);
    }
    return 1;
}
